package com.qige.dome.homework;

/**
 * @Author qige
 * @Date 2024-08-07 18:38
 * @Description
 */
public class homework1 {
    /*
    第一题：
    使用开启线程方式一：演示主线程和子线程交替执行，并给子线程设置名称
     */
    public static void main(String[] args) {
        MyThread t1 = new MyThread("线程A");
        t1.start();
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + "线程正在打印:" + i);
        }
    }
}
class MyThread extends Thread {
    public MyThread(){

    }
    public MyThread(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println(Thread.currentThread().getName() + "线程正在打印:" + i);
        }
    }
}